import cv2
import numpy as np


def getFeature(path):
    img = cv2.imread(path)
    if img is None:
        return
    hsv = cv2.cvtColor(img, cv2.COLOR_BGR2HSV)
    h, s, v = cv2.split(hsv)
    color_feature = []

    h_mean = np.mean(h)
    s_mean = np.mean(s)
    v_mean = np.mean(v)
    color_feature.extend([h_mean, s_mean, v_mean])

    h_std = np.std(h)
    s_std = np.std(s)
    v_std = np.std(v)
    color_feature.extend([h_std, s_std, v_std])

    h_skewness = np.mean(abs(h - h.mean()) ** 3)
    s_skewness = np.mean(abs(s - s.mean()) ** 3)
    v_skewness = np.mean(abs(v - v.mean()) ** 3)
    h_thirdMoment = h_skewness ** (1. / 3)
    s_thirdMoment = s_skewness ** (1. / 3)
    v_thirdMoment = v_skewness ** (1. / 3)
    color_feature.extend(
        [h_thirdMoment, s_thirdMoment, v_thirdMoment])

    return color_feature
